import vue from 'vue';
import toast from './toast.vue';

const ToastConstructor =  vue.extend(toast)
const showToast = (text="添加成功，<br>在购物车等你哦",duration=1500)=>{
    const ToastDom = new ToastConstructor({
        el:document.createElement('div'),
        data(){
            return {
                text:text,
            }
        }
    })
    document.body.appendChild(ToastDom.$el)
    setTimeout(() => { 
        document.body.removeChild(ToastDom.$el)
    },duration)
}


export default ()=>{
    vue.prototype.$Toast = showToast;
}